﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Text;
using System.Reflection;
using System.Globalization;
using System.Linq;
using System.Xml.XPath;
using System.Xml.Linq;
using System.Collections;
namespace LM.CaptchaControl
{
    public class GlobalResources
    {
        public static string GetResource(string Key, string CaptachCulture)
        {
            string sValue = "";
            string sResourceSounds = "LM.messages." + CaptachCulture.ToLower() + ".xml";

            using (Stream reader = Assembly.GetExecutingAssembly().GetManifestResourceStream(sResourceSounds))
            {
                XDocument doc = XDocument.Load(reader);
                IEnumerable query = (IEnumerable)doc.XPathEvaluate("/MESSAGES/" + Key);
                foreach (var x in query.Cast<XElement>())
                {
                    sValue = x.Value;
                    break;
                }
                //var myresorce = doc.Root.Elements("MESSAGES").Select(x => x.Element(Key));
                //sValue = myresorce.ToString();
            }
            return sValue;
        }
    }
}
